/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * DirectMessageItem.java
 *
 * Created on 30-Jul-2011, 16:41:20
 */
package twitterclient;

import java.awt.Component;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
import twitter.twitteroauth.twitterresponse.StatusType;

/**
 *
 * @author Kevin Doyle
 */
public class DirectMessageItem extends javax.swing.JPanel implements ListCellRenderer{

    /** Creates new form DirectMessageItem */
    public DirectMessageItem() {
        initComponents();
    }
@Override
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean sel, boolean focus) {

        StatusType st = (StatusType) value;
        //put the username into the text box with the txt message 23/07/11 - KD
        String directmessages =(st.getUser().getScreenName());

        jTextPane1.setText(directmessages.toUpperCase()+": "+st.getText());
        return this;
}
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTextPane1 = new javax.swing.JTextPane();

        setBackground(new java.awt.Color(204, 204, 255));
        setPreferredSize(new java.awt.Dimension(550, 50));

        jTextPane1.setBackground(new java.awt.Color(204, 102, 255));
        jTextPane1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jTextPane1.setMinimumSize(new java.awt.Dimension(4, 18));
        jTextPane1.setPreferredSize(new java.awt.Dimension(546, 20));
        jScrollPane1.setViewportView(jTextPane1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 559, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 52, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextPane jTextPane1;
    // End of variables declaration//GEN-END:variables
}
